<% String tempShopId = (String)request.getAttribute("tempShopId"); %>
<% String userId = (String)request.getAttribute("userId");%>
<%
if(true){//改成下载
	response.sendRedirect("http://www.storeme.cn/mall/app/download.jsp?shopId="+(tempShopId==null?"":tempShopId)+"&userId="+(userId==null?"":userId));
	return;
}
%>
<!DOCTYPE html>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/v1/pages/public/taglibs.jsp"%>
<head>

<!-- Basic Page Needs
================================================== -->
<meta charset="utf-8" />
<title>云便利商店</title>

<!-- Mobile Specific
================================================== -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<!-- CSS
================================================== -->
<link rel="stylesheet" type="text/css" href="${ctx}/reg/css/style.css" />
<!-- Java Script
================================================== -->
<script type="text/javascript">
</script>
<script src="${ctx}/reg/js/jquery.min.js"></script>
<script src="${ctx}/reg/js/basic.js"></script>
<script src="${ctx}/js/get2post.js" type="text/javascript"></script>
<script src="${ctx}/js/ddf_ajax.js" type="text/javascript"></script>
<script src="${ctx}/js/jquery.form.js" type="text/javascript"></script>
<script src="${ctx}/js/md5.js" type="text/javascript"></script>
<script type="text/javascript">
var ctx = "${ctx}";
/**
 * 发送短信验证码
 */
function sendMessage(mobile){
	if(mobile!=null){
		var sign = MD5(mobile+"_sms_");
		DDF_AsyncRequest("POST", ctx+"/shopweb/Reg/sendValidateCode.do", "mobile="+mobile+"&sign="+sign, "sendValidateCodeCallBack(data);");
	}
}

function sendValidateCodeCallBack(data){
	if(data != null && data.code != "1"){
		showTips(data.message);
	}else{
			showTips("发送成功！");
	}
}
/**
 * 验证手机号是否注册过
 * @param mobile
 */
function validateMobile(){
	var mobile = $("#mobile").val();
	var patrn = /^0{0,1}(13[0-9]|15[0-9]|18[0-9]|14[0-9]|17[0-9])[0-9]{8}$/;
	if(!validateOne(patrn,mobile)){
		$("#erro_reg_message").html("手机号非法");
		showTips();
	}else{
		get_time();
		var sign = MD5(mobile+"_sms_");
		DDF_AsyncRequest("POST", ctx+"/shopweb/Reg/validateMobile.do", "mobile="+mobile+"&sign="+sign, "validateCallBack(data);");
	}
}
/**
 * 单个验证
 * @param exp 正则表达式
 * @param param 要验证的参数
 */
function validateOne (exp,param){
	 if(!exp.exec(param)){
		 return false;
	 }else{
		 return true;
	 }
}
/**
 * 验证手机号是否注册回调函数
 * 
 */
function validateCallBack(data){
	if(data != null && data.code != "1"){
		showTips(data.message);
	}else if(data != null && data.code == "1"){
		var mobile = $("#mobile").val();
		sendMessage(mobile);
	}
}
function reg(){
	var password = $("#password").val();
	var oncePwd = $("#oncePassword").val();
	/* if(!Validator.Validate($('#shop_register')[0])){
		return false;
	} */
	if(password != oncePwd){
		showTips("两次密码不一样");
	}else{
		var params= {
				mobile : $("#mobile").val(),
				password : MD5(password),
				validateCode : $("#validateCode").val(),
				shopId : "<%= tempShopId==null?"":tempShopId %>",
				tempUserId : "<%= userId==null?"":userId %>"
		};
		DDF_AsyncRequest("POST",ctx+"/shopapp/Reg/registerByOthers.do",params,"registerCallBack(data)");
	}
}
/**
 * 注册_回调函数
 */
function registerCallBack(data){
	if(data != null && data.code =="-10001"){
		showTips(data.message);
	}
	if(data != null && data.code =="-3210"){
		showTips(data.message);
	}
	if(data != null && data.code == "1"){
		get2post(ctx+"/reg/reg_success.jsp");
	}
}
function showTips(msg){
	$("#erro_reg_message").html(msg);
    $("#tips").fadeIn(500);	
	 setTimeout(function(){$("#tips").fadeOut(800);},1500);
}
</script>
<!-- Styles Switcher
================================================== -->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<div class="header">
  <div class="header_middle">注册</div>
</div>

<div  class="main">
    
     <div class="register_top">
      <div class="register_title">注册抢200积分！<i class="icon_down"></i></div>
         <div class="register_con">
             <p>成功注册成为会员，马上送您200积分！</p>
             <p>邀请好友注册，再送您50积分！</p>
             <p>下载APP购物，还有更多积分等着您！</p>
             <p>积分有啥用？注册一下，有你好看！</p>
         </div>
     	<!-- 
         <div class="register_title">欢迎注册<i class=""></i></div>
         <div class="register_con">
             <p>欢迎邀请好友注册！</p>
         </div>
        -->
     </div>  
     <form id="shop_register" action="#" method="post" >
     <div class="containers"> 
       <div class="login"><input type="text" id="mobile" name="mobile" class="login_input" placeholder="手机号码"/></div>
       <div class="login"><input type="text" id="validateCode" name="validateCode" class="captcha_input" placeholder="短信验证码"/><input id="time_btn" class="captcha_button" type="button" value="免费获取验证码" onClick="validateMobile();" /></div>  
       <div class="clear"></div>
       <div class="login"><input type="password" id="password" name="password"class="login_input" placeholder="登录密码"/></div>
       <div class="login"><input type="password" id="oncePassword" class="login_input" placeholder="确认密码"/></div>            
       <div class="login">
       </div>
       
       <div class="clear"></div>    
       <div class="login"><input type="button" class="input_button" value="注册云便利商店" onClick="reg();" /></div>
       <!-- <div class="login iphone"><input type="button" class="blue_button" value="已注册 直接下载APP(苹果)" onClick="window.location.href='https://itunes.apple.com/us/app/dui-dui-fu/id875224684?l=zh&ls=1&mt=8'"/></div> -->
       <div class="login android"><input type="button" class="blue_button" value="已注册 直接下载APP(安卓)" onClick="window.location.href='http://www.storeme.cn/mall/shopapp/Update/download.do?shopId=<%=tempShopId==null?"":tempShopId %>&userId=<%=userId==null?"":userId%>'"/></div>
       <div class="login"><p class="help_block">若长时间未收到验证码短信，请联系客服 <span class="color_red">400-029-0823</span></p></div>    
    </div> 
	</form>
         
</div>     
		<div id="tips"><span id="erro_reg_message"></span></div> 
		<div class="weixin_android"><div class="login i_know" ><input type="button" class="input_button" value="我知道了！先注册" onClick="close_tip()" /></div></div>
		<div class="weixin_iphone"><div class="login i_know" ><input type="button" class="input_button" value="我知道了！先注册" onClick="close_tip()" /></div></div>
</body>
</html>